package com.edu.service.impl;

import com.edu.service.BookService;

/*
 * @Author:mx
 * @Date:2025/11/10-10:24:08
 */
public class BookServiceProxy implements BookService {

    private BookService bs;

    public BookServiceProxy(BookService bookService) {
        this.bs = bookService;
    }

    @Override
    public void addBook() {
        long begin = System.currentTimeMillis();
        bs.addBook();//代理对象的核心业务 还是由 被代理对象来执行
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end-begin));
    }

    @Override
    public void deleteBook() {
        long begin = System.currentTimeMillis();
        bs.deleteBook();
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end-begin));
    }

    @Override
    public void updateBook() {
        long begin = System.currentTimeMillis();
        bs.updateBook();
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end-begin));
    }

    @Override
    public void selectBook() {
        long begin = System.currentTimeMillis();
        bs.selectBook();
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end-begin));
    }
}
